﻿/**
 * Created by Administrator on 2017/8/28.
 */
define(function () {
    var ShowContact = {
        name: 'show-contact',
        template: ''
        + '<span class="cnnt_sj_xl">'
        + '   <Row>'
        + '       <Col span="8">'
        + '           <i-menu >'
        + '               <Submenu name="cnnt_3">'
        + '                   <template slot="title">'
        + '                       <Icon type="ios-paper"></Icon>'
        + '                       {{usuallyContact.TypeText}}：{{usuallyContact.ContactValue}}'
        + '                   </template>'
        + '                   <Menu-item name="1-1">'
        + '                       <div class="menuIte-bg" v-for="(item,index) in unusuallyContactList" v-on:click="changeContactUsually(index)">{{item.TypeText}}：{{item.ContactValue}}</div>'
        + '                   </Menu-item>'
        + '               </Submenu>'
        + '           </i-menu>'
        + '       </Col>'
        + '   </Row>'
        + '</span>',
        props: {
            contactValueList: Array,
            relationId: String,
        },
        data: function () {
            return {};
        },
        computed: {
            usuallyContact: function () {
                var c = { TypeText: "手机", ContactValue:""};
                for (var i = 0; i < this.contactValueList.length; i++) {
                    if (this.contactValueList[i].IsUsually)
                    {
                        return this.contactValueList[i];
                    }
                }
                return c;
            },
            unusuallyContactList: function () {
                var contactList = [];
                for (var i = 0; i < this.contactValueList.length; i++) {
                    if (!this.contactValueList[i].IsUsually) {
                        contactList.push(this.contactValueList[i]);
                    }
                }
                return contactList;
            },
        },
        methods: {
            changeContactUsually: function (index) {
                //触发changeContactUsually
                window.bus.$emit("changeContactUsually", {
                    RelationId: this.relationId,
                    Type: this.unusuallyContactList[index].Type,
                    ContactValue: this.unusuallyContactList[index].ContactValue,
                });
            }
        },
        mounted: function () {
        },
    };
    return ShowContact;
});

